const path = require("path")
const files = require.context("@/config", false, /\.js$/);
export default {
	data() {
		let configs = {ruleList:{}};
		files.keys().forEach((key) => {
		  const name = path.basename(key, ".js")
		  //console.log('config.name',name);
		  if (name!=='index'){
			  configs[name.toUpperCase()] = files(key).default || files(key);
		  }
		  
		})
		return configs;
	},
	methods: {
		open(name,val){
			//console.log(val);
			if (this.$refs[name]){
				if (this.$refs[name].open){
					this.$refs[name].open(val);
				}else{
					this.$refs[name][0].open(val);
				}
			}
				
		},
		openPopup(name,val){
			//console.log(val);
			if (this.$refs[name]){
				if (this.$refs[name].open){
					this.$refs[name].open(val);
				}else{
					this.$refs[name][0].open(val);
				}
			}
				
		},
		closePopup(name,val){
			if (this.$refs[name]){
				if (this.$refs[name].close){
					this.$refs[name].close(val);
				}else{
					this.$refs[name][0].close(val);
				}
			}			
		},
		close(name,val){
			if (this.$refs[name]){
				if (this.$refs[name].close){
					this.$refs[name].close(val);
				}else{
					this.$refs[name][0].close(val);
				}
			}				
		},
		checkRuleChange(group,name,value){
			if (group){
				if (value){
					this.ruleList[group][name]=value;
				}else{
					delete this.ruleList[group][name];
				}
			}else{
				if (value){
					this.ruleList[name]=value;
				}else{
					delete this.ruleList[name];
				}
			}

			
		},
	}
}
